class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution:
    def deleteDuplicates(self, head: ListNode):
        pre = ListNode(None)
        pre.next = head
        cur = head
        while cur:
            if pre and pre.val == cur.val:
                pre.next = cur.next
                cur.next = None
                cur = pre.next
                continue
            pre = cur
            cur = cur.next
        return head

if __name__ == '__main__':
    s = Solution()
    node1 = ListNode(1)
    node2 = ListNode(1)
    node3 = ListNode(2)
    node4 = ListNode(3)
    node5 = ListNode(3)
    node1.next = node2
    node2.next = node3
    node3.next = node4
    node4.next = node5
    node = s.deleteDuplicates(node1)
    while node:
        print(node.val)
        node = node.next